package com.metaera.app.ui.fragments;


import android.graphics.Color;
import android.graphics.drawable.Drawable;
import android.os.Bundle;
import android.view.View;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.viewholder.BaseViewHolder;
import com.metaera.app.LocalConfigStore;
import com.metaera.app.R;
import com.metaera.app.controller.PaginationContract;
import com.metaera.app.controller.PaginationContractFactory;
import com.metaera.app.controller.core.IPaginationPresenter;
import com.metaera.app.controller.core.SimplePaginationPresenter;
import com.metaera.app.controller.view.core.IPaginationView;
import com.metaera.app.data.DataRepository;
import com.metaera.app.data.model.ArticleListResponse;
import com.metaera.app.data.model.BasicListResponse;
import com.metaera.app.data.model.HotColumnResponse;
import com.metaera.app.data.model.UserDetailsResponse;
import com.metaera.app.data.network.ApiParam;
import com.metaera.app.ui.adapters.HomeFollowNewsAdapter;
import com.metaera.app.ui.adapters.HotColumnAdapter;
import com.metaera.app.ui.core.BaseRequestFragment;
import com.metaera.app.utils.ViewUtils;
import com.metaera.app.utils.event.LogoutEvent;
import com.metaera.app.utils.image.GlideApp;
import com.scwang.smart.refresh.layout.SmartRefreshLayout;

import org.greenrobot.eventbus.Subscribe;

import androidx.core.content.ContextCompat;
import androidx.recyclerview.widget.DividerItemDecoration;
import androidx.recyclerview.widget.RecyclerView;
import io.reactivex.Observable;

/**
 * 首页关注者的新闻列表
 */
@Deprecated
public class HomeFollowNewsFragment extends BaseRequestFragment {

    @Override
    protected int getLayoutId() {
        return R.layout.include_smart_refresh_recycler_view;
    }

    @Override
    protected boolean useEventBus() {
        return true;
    }

    @Override
    protected void initialize(Bundle savedInstanceState) {
        RecyclerView recyclerView = findViewById(R.id.recycler_view);
        SmartRefreshLayout refreshLayout = findViewById(R.id.smart_refresh_layout);

        PaginationContractFactory factory = new PaginationContractFactory();

        if (LocalConfigStore.getInstance().isLogin()) {
            // 已经登录，但没有关注用户时，显示热门专栏
            // 点击关注专栏后刷新列表，显示关注者文章
            factory.followArticle().init(recyclerView, this, refreshLayout);

        } else {
            factory.hotColumn().init(recyclerView, this, refreshLayout);
        }

    }

    @Subscribe
    public void event(UserDetailsResponse user) {
        initialize(null);
    }

    @Subscribe
    public void event(LogoutEvent user) {
        initialize(null);
    }

}
